package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.*;
import cn.gson.fengboot.model.pojos.Qxinz;
import cn.gson.fengboot.model.service.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/par")
public class ChanguigcxContrpller {

    @Autowired
    QguigeService qguigeService;

    @Autowired
    QleibiecxService qleibiecxService;

    @Autowired
    QguigeminService qguigeminService;

    @Autowired
    QleixinminService qleixinminService;

    @RequestMapping("/guige-list")
    @ResponseBody
    //规格查询及分页
    public Map<String ,Object> select1(Integer pageNum, Integer PageSize,String input23,String value7){
        Page<Object> obj= PageHelper.startPage(pageNum,PageSize);
        qguigeService.qmodelList(input23,value7);
        Map<String,Object> map=new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }
//规格名查询
    @RequestMapping("/niuniu-list")
    @ResponseBody
    public List<Qmodel> proList(){
        return qguigeminService.qmodelListt();
    }

    //类型名查询
    @RequestMapping("/gougou-list")
    @ResponseBody
    public List<QtypeEntity> leixinmin(){
        return qleixinminService.qtypeEntityList();
    }
    //规格名新增
    @RequestMapping("/ggmxz-chanp")
    @ResponseBody
    public  void addguigemin(@RequestBody Qmodel qmodel){
       qguigeminService.addguigemin(qmodel);

    }
    @RequestMapping("/ggzxz-chanp")
    @ResponseBody
    public  void addguigezhi(@RequestBody Qmodeldetails qmodeldetails){
        System.out.println(qmodeldetails);
        qguigeminService.addguigezhi(qmodeldetails);

    }
    //物理删除
    @RequestMapping("/delete-cpgg")
    @ResponseBody
    public void deleteById(int idd){
        qguigeService.deleteById(idd);
    }

    //类型页面查询
    @RequestMapping("/leibie-chaxun")
    @ResponseBody
    public List<Qleibievo> allFunctionType(){
        return qleibiecxService.allFunctionType();
    }
    //类型页面查询
    @RequestMapping("/qtype-chaxun")
    @ResponseBody
    public List<QtypeEntity> leibielist(){
        return qleibiecxService.leibielist();
    }
    //类型新增
    @RequestMapping("/addleix")
    @ResponseBody
    public  void addleibie(@RequestBody QtypeEntity qtypeEntity){
        qleibiecxService.addleibie(qtypeEntity);

    }
}
